package TestDemo;

public class Animal {
    String name;
    int age;

    public void eat() {
        System.out.println(name + "吃饭真香~");
    }

    public void sleep() {
        System.out.println(name + "睡觉中~");
    }
}

class Dog extends  Animal {
    void woof() {
        System.out.println(name + "汪汪~");
    }
}

class Cat extends Animal {
    void meow() {
        System.out.println(name + "喵喵~");
    }
}

class Test {
    public static void main(String[] args) {
        Dog dog = new Dog();
        //Dog类中并没有定义任何成员把变量，name和age属性是从父类Animal中继承下来的
        System.out.println(dog.name);
        System.out.println(dog.age);

        //Dog访问的eat()和sleep()方法也是从Animal中继承下来的
        dog.eat();
        dog.sleep();

        dog.woof();
    }
}